From 48329bfc96bd21ce922e1954c8a912ee7f85b519 Mon Sep 17 00:00:00 2001 From: robertl Date: Sun, 1 Feb 2004 05:09:09 +0000 Subject: [PATCH] A number of changes suggested by Kjeld to make this play nicer with geocaching gpx files. --- gpsbabel/cetus.c | 68 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 16 deletions(-) diff --git a/gpsbabel/cetus.c b/gpsbabel/cetus.c index df0af8548..60a8e74cf 100644 --- a/gpsbabel/cetus.c +++ b/gpsbabel/cetus.c @@ -27,6 +27,22 @@ #define MYTYPE 0x43577074 /* CWpt */ #define MYCREATOR 0x63475053 /* cGPS */ +#define NOTESZ 4096 +#define DESCSZ 4096 + +typedef enum { + WptEdit = 0, /* the position has been edited or it was */ + /* imported from another source */ + WptGPS2D = 1, /* retrieved from a GPS with a 2D fix */ + WptGPS3D = 2, /* retrieved from a GPS with a 3D fix */ + WptDGPS2D = 3, /* retrieved from a GPS with a 2D fix and DGPS signal */ + WptDGPS3D = 4, /* retrieved from a GPS with a 3D fix and DGPS signal */ + WptAverage = 5, /* averaging over 3D positions */ + WptCache = 50, /* this position is a geocache reference */ + WptGarmin = 70 /* this position was imported from a Garmin GPS */ + /* the icon field contains the garmin symbol number */ +} wpt_type; + struct record { char type; @@ -194,14 +210,16 @@ data_read(void) static void -cetus_writewpt(waypoint *wpt) +cetus_writewpt(const waypoint *wpt) { struct record *rec; static int ct; struct tm *tm; char *vdata; + char *desc_long; + char *desc_short; - rec = xcalloc(sizeof(*rec)+1018,1); + rec = xcalloc(sizeof(*rec)+18 + NOTESZ + DESCSZ,1); if (wpt->creation_time && (NULL != (tm = gmtime(&wpt->creation_time)))){ rec->min = tm->tm_min; @@ -252,16 +270,34 @@ cetus_writewpt(waypoint *wpt) vdata[0] ='\0'; } vdata += strlen( vdata ) + 1; - - if ( wpt->description ) { - strncpy( vdata, wpt->description, 501 ); - vdata[500] = '\0'; + + if (wpt->gc_data.desc_short.utfstring) { + char *stripped_html = strip_html(&wpt->gc_data.desc_short); + desc_short = xstrdup("\n\n"); + desc_short = xstrappend(desc_short, str_utf8_to_cp1252(stripped_html)); + xfree(stripped_html); + } else { + desc_short = xstrdup(""); } - else { - vdata[0] ='\0'; + + if (wpt->gc_data.desc_long.utfstring) { + char *stripped_html = strip_html(&wpt->gc_data.desc_long); + desc_long = xstrdup("\n\n"); + desc_long = xstrappend(desc_long, str_utf8_to_cp1252(stripped_html)); + xfree(stripped_html); + } else { + desc_long = xstrdup(""); } + snprintf(vdata, DESCSZ, "%s%s%s", + wpt->description ? wpt->description : NULL, + desc_short, + desc_long); + + xfree(desc_short); + xfree(desc_long); + if (appendicon && wpt->icon_descr) { - int left = 500 - strlen( vdata ); + int left = DESCSZ - strlen( vdata ); int ilen = strlen( wpt->icon_descr ); if (ilen && left > (ilen+3)) { strcat( vdata, " (" ); @@ -270,13 +306,13 @@ cetus_writewpt(waypoint *wpt) } } vdata += strlen( vdata ) + 1; - - if ( wpt->notes ) { - /* RER note: this doesn't seem to be viewable in Cetus 1.2b2 */ - strncpy( vdata, wpt->notes, 501 ); - vdata[500] = '\0'; - } - else { + + if (wpt->gc_data.hint) { + rec->type = WptCache; + strncpy( vdata, wpt->gc_data.hint, NOTESZ + 1 ) ; + vdata[NOTESZ] = '\0'; + } else { + rec->type = WptEdit; vdata[0] ='\0'; } vdata += strlen( vdata ) + 1; -- 2.30.2